/**
 * @file main.cpp
 * @author RittoQin (1264145445@qq.com)
 * @brief 
 * @version 1.0
 * @date 2022/4/18
 *
 * @copyright Copyright SCUT RobotLab(c) 2022
 *
 */

#include <iostream>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include "RSVideoCapture.h"
#include "Yolo.h"

using namespace std;
using namespace cv;

int delay = 1;

int main(int agrc, char *argv[]) {
    Yolo yolo;
    VideoCapture cap(0);
    Mat color;
    int64 start = getTickCount();
    int64 end;
    int num = 0;
    start = getTickCount();
    while (cap.read(color)) {
        auto boxes = yolo.inference(color);
        yolo.drawBox(color, boxes);
        imshow("output", color);

        end = getTickCount();
        ++num;
        double fps = num * getTickFrequency() / double(end - start);
        char text[32];
        sprintf(text, "fps: %.1f", fps);
        cout << text << endl;

        char c = waitKey(delay);
        if (c == 32) {
            if (delay) delay = 0;
            else delay = 1;
        } else if (c == 27) break;
    }

    return 0;
}